<template>
  <div class="js-x5" v-if="!getIsPhone">
    <select-number-public
      :options="options"
      :winningInfo="winningInfo"
      :winningNumbers="winningNumbers"
      @mutate="handleMutate"
      
    >
      <template v-slot:winninginfo>
        <winning-numbers :winningNumbers="winningNumbers">
          <winning-info-ssc :winningNumbers="winningNumbers"></winning-info-ssc>
        </winning-numbers>
      </template>
      <transition name="fade" mode="out-in">
        <component :is="getCurrentComponent"></component>
      </transition>
    </select-number-public>
  </div>
  <div v-else class="js-x5-phone">
    <div class="fixed-top">
      <winning-numbers :winningNumbers="winningNumbers">
        <div class="numbers">
          <span class="border-right" v-for="(number, index) in winningNumbers.previous.numbers.split(',')" :key="index">{{number}}</span>
        </div>
      </winning-numbers>
      <sub-dropdown-phone></sub-dropdown-phone>
    </div>
    <transition name="fade" mode="out-in">
      <component :is="getCurrentComponent"></component>
    </transition>
    <side-slider-phone :options="options" @click="handleMutate"></side-slider-phone>
  </div>
</template>

<script>
import WinningNumbers from '@/components/winning-numbers/winning-numbers'
import SelectNumberPublic from '@/components/select-number-public/select-number-public'
import zuxuandantuo from '@/components/lottery-type/jsxuan5/qiansan/zuxuandantuo'
import wuxingdingweidan from '@/components/lottery-type/jsxuan5/dingweidan/wuxingdingweidan'
import SideSliderPhone from '@/components/base/phone/side-slider-phone/side-slider-phone'
import SubDropdownPhone from '@/components/base/phone/sub-dropdown-phone/sub-dropdown-phone'
import WinningInfoSsc from '@/components/winning-info/winning-info-ssc'

import { mapGetters, mapMutations } from 'vuex'

export default {
  components: {
    SelectNumberPublic,
    zuxuandantuo,
    wuxingdingweidan,
    SideSliderPhone,
    SubDropdownPhone,
    WinningNumbers,
    WinningInfoSsc
  },
  data() {
    return {
      // 开奖信息
      winningNumbers: {
        id: 'js11x5',
        lotteryName: '极速11选5',
        dateNo: '819048',
         previous: {
          dateNo: '819048',
          numbers: '1,2,3,4,9,10',
          context: '13,大,小,单,双,龙,闲',
        },
        closeTime: new Date().getTime() + 1000000,
        drawTime: new Date().getTime() + 10000000
      },
      // 上期中奖信息
      winningInfo: [
        { 
          id: 1,
          series: 819049,
          numbers: '1,2,3,4,5'
        },
        {
          id: 2,
          series: 819049,
          numbers: '1,2,3,4,5'
        },
        {
          id: 3,
          series: 819049,
          numbers: '1,2,3,4,5'
        },
        {
          id: 4,
          series: 819049,
          numbers: '1,2,3,4,5'
        },
        {
          id: 5,
          series: 819049,
          numbers:'1,2,3,4,5'
        },
        {
          id: 6,
          series: 819049,
          numbers: '1,2,3,4,5'
        },
        {
          id: 7,
          series: 819049,
          numbers: '1,2,3,4,5'
        },
        {
          id: 8,
          series: 819049,
          numbers: '1,2,3,4,5'
        },
        {
          id: 9,
          series: 819049,
          numbers: '1,2,3,4,5'
        }
      ],
      // tab选项
      options: [
        {
          id: 'q_s',
          context: '前三',
          currentComponent: 'zuxuandantuo',
          currentSubTab: '直选',
          currentSubId: 'zx_dt',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 'qs_zx',
                  context: '直选',
                  components: ''
                },
                {
                  id: 'qs_zux',
                  context: '组选',
                  components: ''
                },
                {
                  id: 'zx_dt',
                  context: '组选胆拖',
                  components: 'zuxuandantuo'
                }
              ]
            }
          ]
        },
        {
          id: 'z_s',
          context: '中三',
          currentSubId: 1,
          currentComponent: '',
          currentSubTab: '特码包三',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 1,
                  context: '',
                  components: ''
                }
              ]
            }
          ]
        },
        {
          id: 'h_s',
          context: '后三',
          currentSubId: 1,
          currentComponent: '',
          currentSubTab: '',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 1,
                  context: '混合',
                  components: 'tema28hunhe'
                },
              ]
            }
            
          ]
        },
        {
          id: 'q_r',
          context: '前二',
          currentSubId: '',
          currentComponent: '',
          currentSubTab: '',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 'qr_hh',
                  context: '混合',
                  components: 'tema28hunhe'
                },
              ]
            }
            
          ]
        },
        {
          id: 'h_r',
          context: '后二',
          currentSubId: 1,
          currentComponent: '',
          currentSubTab: '',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 'hr_hh',
                  context: '混合',
                  components: 'tema28hunhe'
                },
              ]
            }
            
          ]
        },
        {
          id: 'd_w_d',
          context: '定位胆',
          currentSubId: 'wx_dwd',
          currentComponent: 'wuxingdingweidan',
          currentSubTab: '五星定位胆',
          sub: [
            {
              cate: '玩法',
              tabnames: [
                {
                  id: 'wx_dwd',
                  context: '五星定位胆',
                  components: 'wuxingdingweidan'
                },
              ]
            }
            
          ]
        },
      ],
     
    }
  },
  created() {
    this.setLotteryType({lotteryName: this.winningNumbers.lotteryName, id: this.winningNumbers.id})
    this.setCurrentLotteryDateNo(this.winningNumbers.dateNo)
    this.setCurrentComponent(this.options[0].currentComponent)
    this.setCurrentMainTab({mainTabName: this.options[0].context, id: this.options[0].id })
    this.setCurrentTab({subTabName: this.options[0].currentSubTab, id: this.options[0].currentSubId})
  },
  methods: {
    handleMutate(options) {
      this.options = options
    },
    ...mapMutations('lottery', {
      setLotteryType: 'SET_LOTTERY_TYPE',
      setCurrentComponent: 'SET_CURRENT_COMPONENT',
      setCurrentMainTab: 'SET_CURRENT_MAIN_TAB',
      setCurrentTab: 'SET_CURRENT_TAB',
      setCurrentLotteryDateNo: 'SET_CURRENT_LOTTERY_DATE_NO'
    })
  },
  computed: {
    ...mapGetters('lottery', [
      'getCurrentComponent',
      'getIsPhone'
    ])
  }
}
</script>

<style lang="stylus" scoped>
  @import '~@/assets/styles/variables.styl'
  &.fade-enter, &.fade-leave-to 
    opacity 0
  &.fade-leave, &.fade-enter-to 
    opacity 1
  &.fade-enter-active, &.fade-leave-active 
    transition all 0.2s 
  @media screen and (max-width 750px) 
    .js-x5-phone 
      width 100%
      box-sizing border-box
      padding-top 148px
      .fixed-top 
        position fixed 
        top 48px 
        left 0 
        right 0 
        z-index 9
        background #fff
        .numbers 
          span  
            display inline-block
            width 25px
            height 10px
            line-height 10px
            text-align center
            font-size 18px 
            font-family $sub-font-family
            font-weight 700
            color $color-theme-red 
            box-sizing border-box
</style>